<extend name="Index/index" />
<block name="mycss">
    <link rel="stylesheet" href="__PUBLIC__/css/People.css">
</block>
<block name="main">

    <div class="container">
        <div id="row">
            <div class="col-md-8 col-md-offset-1 list-group pad0">
                <div class="col-md-12 list-group-item">

                    <form id="info" enctype="multipart/form-data">
                        <div class="col-md-2 mt10 pad10">
                            <div id="headimg">
                                <if condition="$info['id'] eq $_SESSION['home']['id']">
                                    <img src="__PUBLIC__/imgs/<{:dirname($info['image']).'/45_'.basename($info['image'])}>" type="button" class="img-rounded center-block" data-toggle="modal" data-target="#headModal" title="头像上传">
                                <else />
                                    <img src="__PUBLIC__/imgs/<{:dirname($info['image']).'/45_'.basename($info['image'])}>" type="button" class="img-rounded center-block">
                                </if>

                            </div>
                        </div>
                        <div class="col-md-10 mt10">
                            <div class="col-md-12 h3">
                                <div><a href="<{:U('People/index',array('uid'=>$info['userinfo']['id']))}>"><{$info.name}></a></div>
                            </div>
                            <div class="col-md-12">
                                <if condition="$info['id'] neq $_SESSION['home']['id']">
                                <div class="backself btn btn-link"><a href="<{:U('People/index')}>">返回个人中心</a></div>
                                <elseif condition="($info['userinfo']['say'] eq null)" />
                                    <div class="btn btn-link">个性签名</div>
                                </if>
                            </div>
                            <div class="col-md-12">
                                <div class="col-md-4 mt10 h4 ">
                                    <{$info['userinfo']['say']?:'<input class="form-control" type="text" name="say" placeholder="个性签名">'}>
                                </div>
                                <div class="col-md-2 mt10">
                                    <{$info['userinfo']['say']?'':'<input class="form-control btn btn-info" type="submit" value="确定">'}>
                                </div>
                            </div>

                            <div class="col-md-12">
                            <if condition="$info['id'] neq $_SESSION['home']['id']">
                            <div class="backself btn btn-link"><a href="<{:U('People/index')}>">返回个人中心</a></div>
                            <elseif condition="($info['userinfo']['address'] eq null) && ($info['userinfo']['vocation'] eq null)" />
                                <div class="btn btn-link">填写居住信息</div>
                            </if>

                            </div>
                            <div class="col-md-12">
                                <div class="col-md-4 mt20 h6">
                                    <{$info['userinfo']['address']?$info['userinfo']['address']:'<input class="form-control" type="text" name="address" placeholder="居住地">'}>
                                </div>
                                <div class="col-md-4 mt20 h6">
                                    <{$info['userinfo']['vocation']?$info['userinfo']['vocation']:'<input class="form-control" type="text" name="vocation" placeholder="从事行业">'}>
                                </div>
                                <div class="col-md-2 mt20">
                                    <{$info['userinfo']['address'] && $info['userinfo']['vocation']?'':'<input class="form-control btn btn-info" type="submit" value="确定">'}>
                                </div>
                            </div>
                            <div class="col-md-12">

                            <if condition="$info['id'] neq $_SESSION['home']['id']">
                            <div class="backself btn btn-link"><a href="<{:U('People/index')}>">返回个人中心</a></div>
                            <elseif condition="($info['userinfo']['company'] eq null) && ($info['userinfo']['position'] eq null)" />
                                    <div class="btn btn-link">填写工作信息</div>
                            </if>

                            </div>
                            <div class="col-md-12">
                                <div class="col-md-4 mt20 h6">
                                    <{$info['userinfo']['company']?$info['userinfo']['company']:'<input class="form-control" type="text" name="company" placeholder="公司或组织名称">'}>
                                </div>
                                <div class="col-md-4 mt20 h6">
                                    <{$info['userinfo']['position']?$info['userinfo']['position']:'<input class="form-control" type="text" name="position" placeholder="你的职位">'}>
                                </div>
                                <div class="col-md-2 mt20">
                                    <{$info['userinfo']['company'] && $info['userinfo']['position']?'':'<input class="form-control btn btn-info" type="submit" value="确定">'}>
                                </div>
                            </div>
                            <div class="col-md-12">
                            <if condition="$info['id'] neq $_SESSION['home']['id']">
                            <div class="backself btn btn-link"><a href="<{:U('People/index')}>">返回个人中心</a></div>
                            <elseif condition="($info['userinfo']['school'] eq null) && ($info['userinfo']['major'] eq null)" />
                                    <div class="btn btn-link">填写教育信息</div>
                            </if>

                            </div>
                            <div class="col-md-12">
                                <div class="col-md-4 mt20 h6">
                                    <{$info['userinfo']['school']?$info['userinfo']['school']:'<input class="form-control" type="text" name="school" placeholder="学校或教育机构">'}>
                                </div>
                                <div class="col-md-4 mt20 h6">
                                    <{$info['userinfo']['major']?$info['userinfo']['major']:'<input class="form-control" type="text" name="major" placeholder="专业方向">'}>
                                </div>
                                <div class="col-md-2 mt20">
                                    <{$info['userinfo']['school'] && $info['userinfo']['major']?'':'<input class="form-control btn btn-info" type="submit" value="确定">'}>
                                </div>
                            </div>
                            <div class="col-md-12">
                                <if condition="$info['id'] neq $_SESSION['home']['id']">
                                <div class="backself btn btn-link"><a href="<{:U('People/index')}>">返回个人中心</a></div>
                                <elseif condition="($info['userinfo']['introduction'] eq null)" />
                                    <div class="mt20 btn btn-link">填写个人简介</div>
                                </if>

                            </div>
                            <div class="col-md-12">
                                <div class="col-md-12 mt20 h6">
                                    <{$info['userinfo']['introduction']?$info['userinfo']['introduction']:'<textarea class="form-control" name="introduction" rows="3" maxlength="100"></textarea>'}>
                                </div>
                                <div class="col-md-2 col-md-offset-10 mt10 h6">
                                    <{$info['userinfo']['introduction']?'':'<input class="form-control btn btn-info" type="submit" value="确定">'}>
                                </div>
                            </div>
                        </div>
                    </form>
                    <div class="col-md-12 ">
                        <div class="col-md-3 col-md-offset-9">
                            <if condition="$info.id eq $_SESSION['home']['id']">
                                <a href="<{:U('People/edit')}>"class="btn btn-sm btn-primary">编辑我的资料</a>
                            <else />
                            <in name="info.id" value="$info.attends.attendids">
                                <span class="people btn btn-sm btn-primary" uid="<{$info.id}>">取消关注</span>
                            <else />
                                <span class="people btn btn-sm btn-primary" uid="<{$info.id}>">关注此人</span>
                            </in>
                            </if>
                        </div>
                    </div>
                </div>
                <div id="butt" class="col-md-12 list-group-item pad0">
<!--                     <a href="<{:U('People/index')}>">
                    <div id="index" class="col-md-1 height40 lheight40 text-center"> <span class="glyphicon glyphicon-home"></span> </div>
                    </a> -->
                    <div id="ask" class="col-md-2 height40 lheight40 text-center">提问<{:count($info['question'])}></div>
                    <div id="answer" class="col-md-2 height40 lheight40 text-center">回答<{:count($info['answer'])}></div>
                    <div id="article" class="col-md-2 height40 lheight40 text-center">文章<{:count($info['article'])}></div>
                    <div id="collect" class="col-md-2 height40 lheight40 text-center">收藏<{:count($info['collect'])}></div>
                </div>
            </div>
            <div class="col-md-3">
                <div id="attends" class="col-md-12">
                    <div id="attend" class="col-md-5">
                        <p>关注了</p>
                        <p><{:count($info[attends][attend])}> 人</p>
                    </div>
                    <div id="attended" class="col-md-5">
                        <p>关注者</p>
                        <p><{:count($info[attends][attended])}> 人</p>
                    </div>
                </div>
            </div>
            <div class="col-md-8 col-md-offset-1 list-group pad0 mt30">
                <div id="show">
                    <div class="index">
                        <div class="col-md-12 list-group-item">最新动态</div>
                        <div class="col-md-12 list-group-item">
                        暂无数据
                        </div>
                    </div>
                    <div class="ask">
                        <empty name="info.question">
                            <div class="col-md-12 list-group-item">暂无数据</div>
                        <else />
                            <div class="col-md-12 list-group-item">
                                <a href="<{:U('People/index',array('uid'=>$info['id']))}>"><{$info.name}></a> &nbsp;的提问
                            </div>
                            <if condition="$info.id eq $_SESSION['home']['id']">
                                <volist name="info.question" id="val" empty="无">
                                <div class="col-md-12 list-group-item">
                                    <a href="<{:U('Question/detail',array('qid'=>$val['id']))}>"><{$val.name}></a>
                                    <div class="col-md-12 h6 pd0 mt10">

                                        <span class="span" question_id="<{$val.id}>">取消关注</span>
                                         &nbsp;&nbsp;<{$val.answer_num}> 人回答 &nbsp;<{$val.attend_num}> 人关注
                                    </div>
                                </div>
                                </volist>
                            <else />
                                <volist name="info.question" id="val" empty="无">
                                <div class="col-md-12 list-group-item">
                                    <a href="<{:U('Question/detail',array('qid'=>$val['id']))}>"><{$val.name}></a>
                                    <div class="col-md-12 h6 pd0 mt10">
                                        <span class="guan" question_id=<{$val.id}> >关注问题</span>
                                        <{$val.answer_num}> 人回答 &nbsp;<{$val.attend_num}> 人关注
                                    </div>
                                </div>
                                </volist>
                            </if>
                        </empty>
                    </div>
                    <div class="answer">
                    <empty name="info.answer">
                        <div class="col-md-12 list-group-item">暂无数据</div>
                    <else />
                        <div class="col-md-12 list-group-item">
                            <a href="<{:U('People/index',array('uid'=>$info['id']))}>"><{$info.name}></a> &nbsp;的回答
                        </div>
                        <if condition="$info.id eq $_SESSION['home']['id']">
                            <volist name="info.answer" id="val" empty="无">
                            <div class="col-md-12 list-group-item">
                                <a href="<{:U('Question/detail',array('qid'=>$val['question_id']))}>"><{$val.question.name}></a>
                                <p><{:html_entity_decode(file_get_contents("./Public/Data/".$val['filename']))}></p>
                                <div class="col-md-12 h6 pd0 mt10">

                                    <span class="span" question_id=<{$val.question_id}> >取消关注</span>
                                     &nbsp;&nbsp;<{$val.question.answer_num}> 人回答 &nbsp;<{$val.question.attend_num}> 人关注
                                </div>
                            </div>
                            </volist>
                        <else />
                            <volist name="info.answer" id="val" empty="无">
                            <div class="col-md-12 list-group-item">
                                <a href="<{:U('Question/detail',array('qid'=>$val['question_id']))}>"><{$val.question.name}></a>
                                <div class="col-md-12 h6 pd0 mt10">
                                    <span class="guan" question_id=<{$val.question_id}> >关注问题</span>
                                    <{$val.question.answer_num}> 人回答 &nbsp;<{$val.question.attend_num}> 人关注
                                </div>
                            </div>
                            </volist>
                        </if>
                    </empty>
                    </div>
                    <div class="article">
                    <empty name="info.article">
                        <div class="col-md-12 list-group-item">暂无数据</div>
                    <else />
                        <div class="col-md-12 list-group-item">
                            <a href="<{:U('People/index',array('uid'=>$info['id']))}>"><{$info.name}></a> &nbsp;的文章
                        </div>
                        <if condition="$info.id eq $_SESSION['home']['id']">
                            <volist name="info.article" id="val" empty="无">
                            <div class="col-md-12 list-group-item">
                                <a href="<{:U('Article/show',array('arid'=>$val['id']))}>"><{$val.title}></a>
                                <p><{:html_entity_decode(file_get_contents("./Public/Data/".$val['filename']))}></p>
                                <div class="col-md-12 h6 pd0 mt10">

                                    <span><{$val.thanks}> 人感谢</span>&nbsp;
                                    <span><{$val.discuss_number}> 条评论 </span> &nbsp;
                                    <{$val.discuss_number}> <span class="glyphicon glyphicon-thumbs-up"></span>&nbsp;
                                    <span><{$val.helpless}> 有用 </span>
                                </div>
                            </div>
                            </volist>
                        <else />
                            <volist name="info.article" id="val" empty="无">
                            <div class="col-md-12 list-group-item">
                                <a href="<{:U('Article/show',array('arid'=>$val['id']))}>"><{$val.title}></a>
                                <p><{:html_entity_decode(file_get_contents("./Public/Data/".$val['filename']))}></p>
                                <div class="col-md-12 h6 pd0 mt10">


                                    <span><{$val.thanks}> 人感谢</span>&nbsp;
                                    <span><{$val.discuss_number}> 条评论 </span> &nbsp;
                                    <{$val.discuss_number}> <span class="glyphicon glyphicon-thumbs-up"></span>&nbsp;
                                    <span><{$val.helpless}> 有用 </span>
                                </div>
                            </div>
                            </volist>
                        </if>
                    </empty>
                    </div>
                    <div class="collect">
                        <empty name="info.collect">
                            <div class="col-md-12 list-group-item">
                                <a href="<{:U('Collections/mine')}>">我的收藏夹</a>
                            </div>
                        <else />
                            collect
                        </empty>
                    </div>
                    <!-- 关注了的用户 -->
                    <div class="attend">
                        <empty name="info.attends.attend">
                            <div class="col-md-12 list-group-item">暂无数据</div>
                        <else />
                        <div class="col-md-12 list-group-item">
                            <div class="col-md-6 mt10">
                                <a href="<{:U('People/index',array('uid'=>$info['userinfo']['id']))}>"><{$info.name}></a> 关注了<{:count($info[attends][attend])}>人
                            </div>
                            <div class="col-md-2 col-md-offset-4 mt20">
                                <a href="<{:U('People/index')}>">返回个人中心</a>
                            </div>
                            <volist name="info.attends.attend" id='val' empty="无">
                                <div class="col-md-1 mt20">
                                    <a href="<{:U('People/index',array('uid'=>$val['id']))}>">
                                        <img src="__PUBLIC__/imgs/<{:dirname($val['image']).'/45_'.basename($val['image'])}>">
                                    </a>
                                </div>
                                <div class="col-md-2 mt20">
                                    <a href="<{:U('People/index',array('uid'=>$val['id']))}>"><{$val.name}></a>
                                </div>
                                <div class="col-md-2 col-md-offset-7 mt20">
                                    <if condition="$info.id eq $_SESSION['home']['id']">
                                        <span class="people btn btn-sm btn-primary" uid="<{$val.id}>">取消关注</span>
                                    <else />
                                    <in name="val.id" value="$info.attends.attendids">
                                        <span class="people btn btn-sm btn-primary" uid="<{$val.id}>">取消关注</span>
                                    <else />
                                        <span class="people btn btn-sm btn-primary" uid="<{$val.id}>">关注此人</span>
                                    </in>
                                    </if>
                                </div>
                            </volist>
                        </div>
                        </empty>
                    </div>
                    <div class="attended">
                    <empty name="info.attends.attended">
                        <div class="col-md-12 list-group-item">暂无数据</div>
                    <else />
                    <div class="col-md-12 list-group-item">
                        <div class="col-md-6 mt10">
                            <a href="<{:U('People/index',array('uid'=>$info['userinfo']['id']))}>"><{$info.name}></a> 被<{:count($info[attends][attended])}>人关注了
                        </div>
                        <div class="col-md-2 col-md-offset-4 mt20">
                            <a href="<{:U('People/index')}>">返回个人中心</a>
                        </div>
                        <volist name="info.attends.attended" id='val' empty="无">
                            <div class="col-md-1 mt20">
                                <a href="<{:U('People/index',array('uid'=>$val['id']))}>">
                                    <img src="__PUBLIC__/imgs/<{:dirname($val['image']).'/45_'.basename($val['image'])}>">
                                </a>
                            </div>
                            <div class="col-md-2 mt20"><a href="<{:U('People/index',array('uid'=>$val['id']))}>"><{$val.name}></a></div>
                            <div class="col-md-2 col-md-offset-7 mt20">

                                <in name="val.id" value="$info.attends.attendids">
                                    <span class="people btn btn-sm btn-primary" uid="<{$val.id}>">取消关注</span>
                                <else />
                                    <span class="people btn btn-sm btn-primary" uid="<{$val.id}>">关注此人</span>
                                </in>
                            </div>
                        </volist>
                    </div>
                    </empty>
                    </div>

                </div>
            </div>
        </div>
    </div>

    <!-- Modal -->
<div class="modal fade" id="headModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="关闭"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">头像上传</h4>
            </div>
            <form action="<{:U('People/headup')}>" method="post" enctype="multipart/form-data">
                <div class="modal-body">
                    <input type="file" name="imgFile">
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="submit" class="btn btn-primary">确认上传</button>
                </div>
            </form>
        </div>
    </div>
</div>

<!-- <{*:V($info)*}> -->
</block>

<block name="myjs">

    <script type="text/javascript">
        $(function(){
            //头像上传按钮
            $('#headimg img').hover(function(){
                $(this).attr('style','cursor:pointer');
                $(this).attr('title','头像上传');
            });



            var butt = 'ask';
            $('#show>div').attr('style','display:none');
            $('.ask').attr('style','display:block');
            //给用户操作绑定划过划出效果以及点击事件
            $('#butt>div').hover(function(){
                $(this).attr('style','background-color:#69f;cursor:pointer');
                var butt = $(this).attr('id');
                // console.log(butt);
                $(this).click(function(){
                    $('#show>div').attr('style','display:none');
                    $('.' + butt).attr('style','display:block');
                    // location.href="<{:U('People/"+ butt +"')}>";
                });
            },function(){
                $(this).attr('style','');
            });
            // 点击事件 用户关注
            $('#attends>div').hover(function(){
                $(this).attr('style','cursor:pointer;');
                var attends = $(this).attr('id');
                $(this).click(function(){
                    $('#show>div').attr('style','display:none');
                    $('.' + attends).attr('style','display:block');
                })
            });



            // 隐藏表单
            $('#info .btn-link').parent().next('div').attr('style','display:none');
            //给btn-link点击事件
            $('.btn-link').click(function(){
                $(this).parent().next('div').attr('style','display:block');
                $(this).attr('style','display:none');
            });
            $('.backself').off("click","");
            // 给提交按钮做点击事件
            for (var i = 0; i <  $('#info :submit').length; i++) {
                $($('#info :submit')[i]).click(function(){
                    var info = $(this).parent().prevAll().children().serialize();//放在两个for之间才可以
            //让确定后的内容直接写入当前位置
                    for (var j = 0; j < $(this).parent().prevAll().length; j++) {
                        var n = $(this).parent().prevAll().children().eq(0).val();
                        // $(this).parent().parent().attr('style','display:block');
                        $(this).parent().prevAll().eq(j).text(n);
                        // console.log(n);
                    };
                        $(this).parent().remove();
                    $(this).parent().parent().attr('style','display:none');
                    $.ajax({
                        type: 'post',
                        url:"<{:U('People/update')}>",
                        data:info,
                        dataType:'json',
                        success:function(data){
                            // $($(this)).parent().parent().prev().attr('style','display:block');
                            // info = data;
                            // console.log(data);
                        }
                    })
                    return false;
                });
            }
// ----------------------------------------ask-----------------------------------
            //取消关注
        $("#show .ask span").attr('style','cursor:pointer;');

            //遍历绑定单击事件
        for (var i = 0; i <  $("#show .ask span[class='span']").length; i++) {
            // console.log($('#show .ask span')[i]);

             $($("#show .ask span[class='span']")[i]).click(function(){//外面哪个$ 是转为jquery DOM 原来是xml DOM
            $(this).parent().parent().attr('style','display:none;');
            // console.log($(this));
            //阿贾克斯提交
            $.ajax({
                type: 'get',
                url:"<{:U('Index/quguan')}>",
                data:'qid=' + $(this).attr('question_id'),
                // dataType:'json',
                success:function(data){
                    var nask = $('#butt>#ask').html().substr(2) - 1;
                    $('#butt>#ask').html('提问' + nask);
                    }
                })//end ajsx

            })//end click
        }//end for
//关注
            //遍历绑定单击事件
        for (var i = 0; i <  $("#show .ask span[class='guan']").length; i++) {
            $($("#show .ask span[class='guan']")[i]).click(function(){
                if ($(this).html()=='关注问题') {
                //阿贾克斯提交
                    $.ajax({
                        type: 'get',
                        url:"<{:U('Index/guan')}>",
                        data:'qid=' + $(this).attr('question_id'),
                        // dataType:'json',
                            });//end ajsx
                    $(this).html('取消关注');
                } else {
                        // console.log('quguan');
                    //阿贾克斯提交
                    $.ajax({
                        type: 'get',
                        url:"<{:U('Index/quguan')}>",
                        data:'qid=' + $(this).attr('question_id'),
                        // dataType:'json',
                        success:function(){
                            }
                        })//end ajsx
                    $(this).html('关注问题');
                }//end else
            })//end click
        }//end for
// ----------------------------------------answer-----------------------------------
//取消关注
        $("#show .answer span").attr('style','cursor:pointer;');

            //遍历绑定单击事件
        for (var i = 0; i <  $("#show .answer span[class='span']").length; i++) {
            // console.log($('#show .answer span')[i]);

            $($("#show .answer span[class='span']")[i]).click(function(){//外面哪个$ 是转为jquery DOM 原来是xml DOM
            $(this).parent().parent().attr('style','display:none;');
            // console.log($(this));
            //阿贾克斯提交
            $.ajax({
                type: 'get',
                url:"<{:U('Index/quguan')}>",
                data:'qid=' + $(this).attr('question_id'),
                // dataType:'json',
                success:function(data){
                    var nanswer = $('#butt>#answer').html().substr(2) - 1;
                    $('#butt>#answer').html('提问' + nanswer);
                    }
                })//end ajsx

            })//end click
        }//end for
//关注
            // 遍历绑定单击事件
        for (var i = 0; i <  $("#show .answer span[class='guan']").length; i++) {
            $($("#show .answer span[class='guan']")[i]).click(function(){
                if ($(this).html()=='关注问题') {
                //阿贾克斯提交
                    $.ajax({
                        type: 'get',
                        url:"<{:U('Index/guan')}>",
                        data:'qid=' + $(this).attr('question_id'),
                        // dataType:'json',
                            });//end ajsx
                    $(this).html('取消关注');
                } else {
                        // console.log('quguan');
                    //阿贾克斯提交
                    $.ajax({
                        type: 'get',
                        url:"<{:U('Index/quguan')}>",
                        data:'qid=' + $(this).attr('question_id'),
                        // dataType:'json',
                        success:function(){
                            }
                        })//end ajsx
                    $(this).html('关注问题');
                }//end else
            })//end click
        }//end for
        $(".people").click(function(){
            if ($(this).html() == '关注此人') {
                $.ajax({
                    type: 'get',
                    url:"<{:U('Attend/attendU')}>",
                    data:'id=' + $(this).attr('uid'),
                })
                $(this).html('取消关注');
            } else {
                $.ajax({
                    type: 'get',
                    url:"<{:U('Attend/notAttendU')}>",
                    data: 'id=' + $(this).attr('uid'),
                })
                $(this).html('关注此人');
            }
        });



















        });
    </script>
    
</block>